package engine;

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;

public class Actor extends Dynamic implements Comparable<Actor> {

	private int depth = 0;

	// CONSTRUCTOR

	public Actor() {}

	// Getters and setters

	public int getDepth() {
		return depth;
	}

	public void setDepth(int depth) {
		this.depth = depth;
	}

	/** Gets the sub-Actors in this Actor for step and painting. No collision is checked for sub-actors. **/
	protected ArrayList<Actor> getSubActors() {
		return new ArrayList<Actor>();
	}

	//

	public Rectangle2D getBounds() {
		return getSpr().getBounds(getXPos() - getSpr().getXOrigin(), getYPos() - getSpr().getYOrigin(), getSprXScale(), getSprYScale(), (int) getSprIndex(),
			getSprIndexOOBB());
	}

	public float distanceTo(Actor a) {
		return (float) java.awt.Point.distance(getXPos(), getYPos(), a.getXPos(), a.getYPos());
	}

	public boolean intersects(Actor a) {
		return distanceTo(a) < getRadius() + a.getRadius();
	}

	public void collide(Actor actor) {}

	public void paint(Graphics2D g) {
		super.paint(g, (int) getXPos(), (int) getYPos());
	}

	@Override
	public int compareTo(Actor a) {
		return this.getDepth() - a.getDepth();
	}
}
